home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH3
/
SRC
/
RELATIVE.FRM
< prev
next >
Wrap
Text File
|
1996-02-03
|
4KB
|
138 lines
VERSION 4.00
Begin VB.Form RelativeForm
AutoRedraw = -1 'True
Caption = "Relative"
ClientHeight = 2985
ClientLeft = 1950
ClientTop = 1905
ClientWidth = 4860
Height = 3675
Left = 1890
LinkTopic = "Form1"
ScaleHeight = 199
ScaleMode = 3 'Pixel
ScaleWidth = 324
Top = 1275
Width = 4980
Begin VB.PictureBox RelativePict
AutoRedraw = -1 'True
Height = 2700
Left = 2445
ScaleHeight = 2640
ScaleWidth = 2340
TabIndex = 1
Top = 0
Width = 2400
End
Begin VB.PictureBox RGBPict
AutoRedraw = -1 'True
Height = 2700
Left = 0
ScaleHeight = 2640
ScaleWidth = 2340
TabIndex = 0
Top = 0
Width = 2400
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Palette Relative RGB"
Height = 255
Index = 1
Left = 2445
TabIndex = 3
Top = 2760
Width = 2400
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "RGB"
Height = 255
Index = 0
Left = 0
TabIndex = 2
Top = 2760
Width = 2400
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "RelativeForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' ***********************************************
' Fill picture boxes with shades of color.
' ***********************************************
Sub FillPictures()
Const NUM_COLS = 16
Const ROWS_PER_COLOR = 4
Const NUM_ROWS = ROWS_PER_COLOR * 3
Const NUM_BOXES = ROWS_PER_COLOR * NUM_COLS
Dim dx As Single
Dim dy As Single
Dim x As Single
Dim y As Single
Dim clr As Integer
Dim dr As Integer
Dim dg As Integer
Dim db As Integer
Dim i As Integer
Dim j As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
dx = RGBPict.ScaleWidth / NUM_COLS
dy = RGBPict.ScaleHeight / NUM_ROWS
For clr = 1 To 3
dr = 0
dg = 0
db = 0
Select Case clr
Case 1 ' Shades of red.
dr = 255 / NUM_BOXES
Case 2 ' Shades of green.
dg = 255 / NUM_BOXES
Case 3 ' Shades of blue.
db = 255 / NUM_BOXES
End Select
r = 0
g = 0
b = 0
For i = 1 To ROWS_PER_COLOR
x = 0
For j = 1 To NUM_COLS
RGBPict.Line (x, y)-Step(dx, dy), _
RGB(r, g, b), BF
RelativePict.Line (x, y)-Step(dx, dy), _
RGB(r, g, b) + &H2000000, BF
r = r + dr
g = g + dg
b = b + db
x = x + dx
Next j
y = y + dy
Next i
Next clr
End Sub
Private Sub Form_Load()
FillPictures
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub